﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BEPUphysics.Entities;
using Microsoft.Xna.Framework;
using Asplode.InputHandler;
using Asplode.GameEntity.Characters;

namespace Asplode
{

    public class EventDispatcher
    {
        private static EventDispatcher EventDispatcherInstance = new EventDispatcher();

        private EventDispatcher()
        {
        }

        public static EventDispatcher Instance
        {
            get
            {
                return EventDispatcherInstance;
            }
        }

        public delegate void ZombieSpawnHandler(Entity entity);
        public event ZombieSpawnHandler ZombieSpawn;
        public void RaiseZombieSpawn(Entity entity)
        {
            ZombieSpawn(entity);
        }

        public delegate void RemoveEntityHandler(Entity entity);
        public event RemoveEntityHandler RemoveEntity;
        public void RaiseRemoveEntity(Entity entity)
        {
            RemoveEntity(entity);
        }

        public delegate void CursorSpawnHandler(Entity Player, Entity Cursor);
        public event CursorSpawnHandler CursorSpawn;
        public void RaiseCursorSpawn(Entity Player, Entity Cursor)
        {
            if (CursorSpawn != null)
            {
                CursorSpawn(Player, Cursor);
            }
        }

        public delegate void BoxSpawnHandler(Box box, Vector3 initialForce);
        public event BoxSpawnHandler BoxSpawn;
        public void RaiseBoxSpawn(Box box)
        {
            RaiseBoxSpawn(box, Vector3.Zero);
        }
        public void RaiseBoxSpawn(Box box, Vector3 initialForce)
        {
            BoxSpawn(box, initialForce);
        }

        public delegate void DamageHandler(Character source, Character target, float damage);
        public event DamageHandler Damage;
        public void RaiseDamage(Character source, Character target, float damage)
        {
            if (Damage != null)
            {
                Damage(source, target, damage);
            }
        }

        public delegate void ExplosionHandler(Vector3 position, float magnitude, float maxDistance);
        public event ExplosionHandler Explosion;
        public void RaiseExplosion(Vector3 position, float magnitude, float maxDistance)
        {
            Explosion(position, magnitude, maxDistance);
        }

        public delegate void HumanSpawnHandler(Entity entity);
        public event HumanSpawnHandler HumanSpawn;
        public void RaiseHumanSpawn(Entity entity)
        {
            HumanSpawn(entity);
        }

        public delegate void KillHandler(Character killer, Character victim);
        public event KillHandler Kill;
        public void RaiseKill(Character killer, Character victim)
        {
            if (Kill != null)
            {
                Kill(killer, victim);
            }
        }

        public delegate void BoxShotHandler(Entity Box, Vector3 initialForce);
        public event BoxShotHandler BoxShot;
        public void RaiseBoxShot(Entity Box, Vector3 initialForce)
        {
            if (BoxShot != null)
            {
                BoxShot(Box, initialForce);
            }
        }

        public delegate void MortarShotHandler(Entity entity, Vector3 initialForce);
        public event MortarShotHandler MortarShot;
        public void RaiseMortarShot(Entity entity, Vector3 initialForce)
        {
            MortarShot(entity, initialForce);
        }

        public delegate void PlayerAimHandler(Entity entity, Vector3 location);
        public event PlayerAimHandler PlayerAim;
        public void RaisePlayerAim(Entity entity, Vector3 location)
        {
            if (PlayerAim!=null)
            {
                PlayerAim(entity, location);
            }
        }

       
    }
}